package com.iocup.keybastion.context;



import com.iocup.keybastion.authentication.AccessToken;
import com.iocup.keybastion.core.profile.UserProfile;
import lombok.Getter;
import lombok.Setter;

/**
 * @Description: 认证全过程上下文
 * @Author: xyjxust
 * @Date: 2022/3/1 13:05
 */
@Getter
@Setter
public class SecurityContext {
    /**
     * 认证成功后缓存的用户信息
     */
    private UserProfile userProfile;
    /**
     * web上下文持有者  持有request、response的一些功能
     */
    private WebContextHolder webContextHolder;

    /**
     * token
     */
    private AccessToken token;

    public SecurityContext(WebContextHolder webContextHolder) {
        this.webContextHolder = webContextHolder;
    }

    /**
     * 判断当前是否已经认证
     * @return
     */
    public boolean isAuth() {
        return userProfile != null;
    }

}


